﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SportType.aspx.cs" Inherits="Jy123.Web.Manage.AddSportType" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>添加运动类型</title>
    <link href="css/custom/jquery.ui.css" rel="stylesheet" type="text/css" />
    <link href="css/main.css" rel="stylesheet" type="text/css" />

    <script src="js/jquery.js" type="text/javascript"></script>

    <script src="js/jquery.ui.js" type="text/javascript"></script>

    <script src="js/main.js" type="text/javascript"></script>

    <script type="text/javascript" language="javascript">
    
    function Save(){        
        addSportTypeForm.action="SportType.aspx?at=Save";
    }
    function Modify(id){
        var typeIdHidden=document.getElementById("hiddenId");        
        typeIdHidden.value=id;        
        addSportTypeForm.action="SportType.aspx?at=Modify";                
    }        
      $(function(){
        $("#fileLogo").change(function(){
            if(this.value==''){        
                if($("#hiddenType").attr('value')=='Add'){
                    $("#noLogoSpan").css('display','block');
                    $("#errorLogoSpan").css('display','none');
                    $("#typeSubmit").attr('disabled','disabled');
                    return false;
                }else{
                    $("#typeSubmit").attr('disabled','');
                }
            }else{
                $("#noLogoSpan").css('display','none');
               var fileName=this.value;
               var index=fileName.lastIndexOf(".")+1;
               var length=fileName.length-fileName.lastIndexOf(".")-1;                                                  
               var fileType=fileName.substr(index,length);           
               if(fileType=='jpg'||fileType=='gif'||fileType=='tiff'||fileType=='jpeg'||fileType=='png'||fileType=='bmp'){
                    $("#errorLogoSpan").css('display','none');
                    $("#typeSubmit").attr('disabled','');
                    $("#imgLogo").attr('src',this.value);
                   
               }else{
                    $("#errorLogoSpan").css('display','block');
                    $("#typeSubmit").attr('disabled','disabled');
                    return false; 
               }          
            }
            if($("#txtSportType").attr('value')==''){
                $("#noSportTypeSpan").css('display','block');
                $("#sameSportTypeSpan").css('display','none');
                $("#typeSubmit").attr('disabled','disabled');
                return false;
            }
            else{        
                $("#noSportTypeSpan").css('display','none');
                $("#sameSportTypeSpan").css('display','none');
                var count=parseInt($("#countHidden").attr('value'));
                var currentName=$("#txtSportType").attr('value');
                var modifyName=$("#hiddenName").attr('value');                        
                for(var i=0;i<count;i++){                
                    var name = $("#typeHidden"+i.toString()).attr('value');                    
                    if(name==currentName){
                        if($("#hiddenType").attr('value')=='Add'){
                            $("#sameSportTypeSpan").css('display','block');
                            $("#typeSubmit").attr('disabled','disabled');
                            return false;
                        }else if($("#hiddenType").attr('value')=='Update'){                    
                            if(modifyName!=currentName){
                                $("#sameSportTypeSpan").css('display','block');
                                $("#typeSubmit").attr('disabled','disabled');
                                return false;
                            }
                        }
                    }
                }                        
            }        
            
        })
      })
    </script>

    <style type="text/css">
        #imgLogo
        {
            border: 2px solid #CECABC;
            padding: 1px;
            width: 48px;
            height: 48px;
            margin-left: 70px;
            margin-bottom: 15px;
        }
    </style>
</head>
<body>
    <h4>
        <a href="#"><span>运动类型</span></a></h4>
    <form id="addSportTypeForm" action="SportType.aspx" method="post" runat="server">
    <div class="register">
        <h5>
            运动类型：
        </h5>
        <ul>
            <li>
                <input type="text" id="txtSportType" name="txtSportType" class="text" maxlength="20"
                    value="<%=sportTypeName %>" />
                <input type="hidden" id="countHidden" name="countHidden" value="<%=typeCount %>" />
            </li>
            <li><span id="noSportTypeSpan" class="warning1" style="display: none">请填写运动类型名称</span>
                <span id="sameSportTypeSpan" class="warning1" style="display: none">已经存在此运动</span>
            </li>
        </ul>
        <h5>
            比赛时间(分钟)：
        </h5>
        <ul>
            <li>
                <asp:TextBox ID="raceTimeTextBox" runat="server"></asp:TextBox>
            </li>
            <li>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" CssClass="warning" runat="server"
                    ControlToValidate="raceTimeTextBox" ErrorMessage="请填写比赛时间" Display="Dynamic"
                    ForeColor=""></asp:RequiredFieldValidator>
                <asp:RangeValidator ID="moneyRange" CssClass="warning" runat="server" Type="Integer"
                    MinimumValue="1" MaximumValue="200" ControlToValidate="raceTimeTextBox" ErrorMessage="请填写1-200之间的整数"
                    Display="Dynamic" ForeColor=""></asp:RangeValidator>
            </li>
        </ul>
        <h5>
            参赛人数：
        </h5>
        <ul>
            <li>
                <asp:TextBox ID="quantityTextBox" runat="server"></asp:TextBox>
            </li>
            <li>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" CssClass="warning" runat="server"
                    ControlToValidate="quantityTextBox" ErrorMessage="请填写参赛人数" Display="Dynamic"
                    ForeColor=""></asp:RequiredFieldValidator>
                <asp:RangeValidator ID="RangeValidator1" CssClass="warning" runat="server" Type="Integer"
                    MinimumValue="1" MaximumValue="200" ControlToValidate="quantityTextBox" ErrorMessage="请填写1-200之间的整数"
                    Display="Dynamic" ForeColor=""></asp:RangeValidator>
            </li>
        </ul>
        <h5>
            类型描述：
        </h5>
        <ul>
            <li>
                <textarea id="areaDescription" name="areaDescription" rows="6" cols="60" runat="server"></textarea>
            </li>
        </ul>
        <h5>
            Logo：
        </h5>
        <ul>
            <li>
                <input type="file" id="fileLogo" name="fileLogo" class="text" runat="server" />
            </li>
            <li>
                <img alt="Logo" src="" id="imgLogo" />
            </li>
            <li><span id="noLogoSpan" class="warning" style="display: none">请上传一张图片</span> <span
                id="errorLogoSpan" class="warning" style="display: none">请选择正确的图片格式</span></li>
        </ul>
        <ul class="bb">
            <li>
                <input type="hidden" id="hiddenType" name="hiddenType" value="<%=actionType %>" />
                <input type="hidden" id="hiddenId" name="hiddenId" value="<%=typeId %>" />
                <input type="hidden" id="hiddenName" name="hiddenName" value="<%=typeName %>" />
                <input type="submit" id="typeSubmit" name="typeSubmit" class="button" value="保存"
                    onclick="Save()" disabled="disabled" />
            </li>
        </ul>
    </div>
    <%=LoadInitial %>
    </form>
</body>
</html>
